<%  if !@issue.blank? && User.current.allowed_to?(:view_contacts, @project)  %>

<div id="issue_contacts">  
	<style type="text/css">
		#issue_contacts ul {margin: 0;  padding: 0;}
		#issue_contacts li {list-style-type:none; margin: 0px 2px 0px 0px; padding: 0px 0px 0px 0px;}
		#issue_contacts select {width: 95%; display: block;}
		#issue_contacts a.delete {opacity: 0.4;}
		#issue_contacts a.delete:hover {opacity: 1;}
		#issue_contacts img.gravatar {vertical-align: middle; margin: 0 4px 2px 0;} 
	</style>
	
	<div class="contextual">    
		<%= link_to l(:button_add), 
			{:controller => 'contacts_tasks',
			:action => 'add',
	 		:project_id => @project,
			:issue_id => @issue},
			:remote => true if User.current.allowed_to?({:controller => 'contacts_tasks', :action => 'add'}, @project) %>

	 </div>

	
	<h3><%= l(:label_contact_plural) %> </h3>  
	
	<% unless !(@show_form == "true") %>
	 	<%= form_tag( 
            	  {:controller => 'contacts_tasks',
          	              	:action => 'add',
     	                    :issue_id => @issue,
                    		:project_id => @project},
                 :remote => true,
   	             :method => :post,
  	             :id => 'add-contact-form') do |f| %>

			<p><%= select_tag :contact_id, options_for_select(@project.contacts.select("DISTINCT #{Contact.table_name}.*").sort!{|x, y| x.name <=> y.name }.collect {|m| [m.name, m.id]}), :prompt => "--- #{l(:actionview_instancetag_blank_option)} ---" %>

			<%= submit_tag l(:button_add) %>
				<%= link_to l(:button_cancel), {}, :onclick => "$('#add-contact-form').hide(); return false;" %>
		<% end %>
	<% end %>
    
    
	<ul>
	    <% @issue.contacts.visible.each do |contact| %>   
		<li id="contact_<%= contact.id%>">  
		<%= contact_tag(contact) %>	
		<%= "(#{contact.job_title}) " unless contact.job_title.blank? %>     
		<% if  User.current.allowed_to?(:delete_contacts, @project) %>
			<%= link_to(image_tag('delete.png'), 
					{   :controller => 'contacts_tasks',
								:action => 'delete',
								:issue_id => @issue, 
								:project_id => @project,
								:contact_id => contact.id}, 
					:remote => true,
					:method => :delete, 
					:confirm => l(:text_are_you_sure), 
  				 	:class  => "delete",
	   				:title => l(:button_delete) ) %>
					
		 <% end %>   			
		 </li>   			
		<% end %>    
	</ul>

</div>    



<% end %>



